package org.jimmy.tang.collection.iterator;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * @author jimmy
 * 
 */
public class IteratorDemo {
    public static void main(String... arg) {
        Collection<String> a = new ArrayList<String>();
        a.add("Bob");
        a.add("Alice");
        a.add("Lisy");

        Iterator<String> iter = a.iterator();
        while (iter.hasNext()) {
            String ele = iter.next();
            System.out.print(ele + "  ");// Bob Alice Lisy
        }
        System.out.println();

        System.out.println(a);// [Bob, Alice, Lisy]
        Iterator<String> iter2 = a.iterator();
        iter2.next();
        iter2.remove();
        System.out.println(a);// [Alice, Lisy]

    }
}
